﻿using System.Windows.Forms;

namespace Borg.Framework
{
    public class PlugTypeFormatter
    {
        private static object GetLabel(PlugTypeInfo plug)
        {
            var extensionTypeInfo = plug.ExtensionTypeInfo;

            if (extensionTypeInfo is IObjectInfo)
            {
                IObjectInfo objectInfo = (IObjectInfo)extensionTypeInfo;
                return objectInfo.Name;
            }

            return extensionTypeInfo;
        }

        public void OnFormat(object sender, ListControlConvertEventArgs args)
        {
            args.Value = GetLabel((PlugTypeInfo)args.ListItem);
        }
    }
}

